package com.ruoyi.caiwu.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.caiwu.mapper.CurrencyTableMapper;
import com.ruoyi.common.security.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.caiwu.mapper.AccountsMapper;
import com.ruoyi.caiwu.domain.Accounts;
import com.ruoyi.caiwu.service.IAccountsService;

import javax.servlet.http.HttpServletRequest;

/**
 * 账套Service业务层处理
 *
 * @author ruoyi
 * @date 2025-02-25
 */
@Service
public class AccountsServiceImpl implements IAccountsService
{
    @Autowired
    private AccountsMapper accountsMapper;
    @Autowired
    private CurrencyTableMapper currencyTableMapper;
    @Autowired
    private TokenService tokenService;
    /**
     * 查询账套
     *
     * @param accountId 账套主键
    /**
     * 查询账套
     *
     * @param accountId 账套主键
     * @return 账套
     */
    @Override
    public Accounts selectAccountsByAccountId(Long accountId)
    {
        return accountsMapper.selectAccountsByAccountId(accountId);
    }

    /**
     * 查询账套列表
     *
     * @param accounts 账套
     * @return 账套
     */
    @Override
    public List<Accounts> selectAccountsList(Accounts accounts)
    {
        return accountsMapper.selectAccountsList(accounts);
    }

    /**
     * 新增账套
     *
     * @param accounts 账套
     * @return 结果
     */
    @Override
    public int insertAccounts(Accounts accounts)
    {
        accounts.setStartDate(new java.util.Date());
        // 获取当前用户id
        accounts.setUserId(tokenService.getLoginUser().getUserid());
        return accountsMapper.insertAccounts(accounts);
    }

    /**
     * 修改账套
     *
     * @param accounts 账套
     * @return 结果
     */
    @Override
    public int updateAccounts(Accounts accounts)
    {
        return accountsMapper.updateAccounts(accounts);
    }

    /**
     * 批量删除账套
     *
     * @param accountIds 需要删除的账套主键
     * @return 结果
     */
    @Override
    public int deleteAccountsByAccountIds(Long[] accountIds)
    {
        return accountsMapper.deleteAccountsByAccountIds(accountIds);
    }

    /**
     * 删除账套信息
     *
     * @param accountId 账套主键
     * @return 结果
     */
    @Override
    public int deleteAccountsByAccountId(Long accountId)
    {
        return accountsMapper.deleteAccountsByAccountId(accountId);
    }

    @Override
    public List<Accounts> selectAccounts() {
        return accountsMapper.selectAccounts();
    }

}
